/*
 * CompanyInfoDataProvider.java
 * 
 * Created: Jul 21, 2015
 * 
 * Copyright (c) ExpertPB 2015
 * All information contained herein is, and remains the property of
 * ExpertPB and its suppliers, if any.
 */
package com.emex.app.stuff.provider;

import com.emex.app.shared.data.CompanyInfo;
import com.emex.app.shared.data.JuridicalPerson;
import com.emex.app.shared.data.Numbers;
import com.emex.app.shared.ws.CompanyInfoWebService;
import com.emex.app.stuff.utils.WebServiceHelper;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;

/**
 *
 * @author Sergey Karavaev
 */
public class CompanyInfoDataProvider extends Service {

    private CompanyInfoWebService service = null;

    private static CompanyInfoDataProvider instance = null;

    /**
     * Constructor
     */
    private CompanyInfoDataProvider() throws MalformedURLException {
        super(new URL(WebServiceHelper.getDefault().getWebServiceURL("web", "CompanyInfo")),
                WebServiceHelper.getDefault().getWebServiceQName("CompanyInfo"));
        service = getPort(CompanyInfoWebService.class);
    }

    /**
     * Get instance of data provider.
     *
     * @return data provider instance
     */
    public static synchronized CompanyInfoDataProvider getInstance() {
        if (instance == null) {
            new RequestWebService() {
                @Override
                protected void doRequestBody() throws MalformedURLException {
                    instance = new CompanyInfoDataProvider();
                }
            }.doRequest();
        }
        return instance;
    }

    public BindingProvider getBindingProvider() {
        return (BindingProvider) service;
    }

    public CompanyInfo insertCompanyInfo(CompanyInfo record) {
        return service.insertCompanyInfo(record);
    }

    public CompanyInfo getCompanyInfo() {
        return service.getCompanyInfo();
    }

    public CompanyInfo updateCompanyInfo(CompanyInfo record) {
        return service.updateCompanyInfo(record);
    }

    public Numbers insertNumbers(Numbers record) {
        return service.insertNumbers(record);
    }

    public Numbers getNumbers() {
        return service.getNumbers();
    }

    public Numbers updateNumbers(Numbers record) {
        return service.updateNumbers(record);
    }
}
